package org.openmore.consumer.service.feign;

import io.swagger.annotations.ApiParam;
import org.openmore.consumer.dto.common.BaseResponse;
import org.openmore.consumer.entity.enums.TenantStatus;
import org.openmore.consumer.service.feignImpl.TenantServiceImpl;
import org.openmore.consumer.dto.common.TenantDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

import static org.springframework.http.MediaType.APPLICATION_JSON_UTF8_VALUE;

@Service
@FeignClient(value = "openmore-opc", fallbackFactory = TenantServiceImpl.class)
public interface TenantService {

    @RequestMapping(method = RequestMethod.GET, value = "/api/tenant/query")
    public BaseResponse selectAllByPage(@RequestParam(required = false) @ApiParam(value = "创建者ID") String userId,
                                        @RequestParam(required = false) @ApiParam(value = "名称") String name,
                                        @RequestParam(required = false) @ApiParam(value = "应用状态")TenantStatus status,
                                        @RequestParam(required = false) @ApiParam(value = "创建时间") Date createdTimeStart,
                                        @RequestParam(required = false) @ApiParam(value = "创建时间") Date createdTimeEnd,
                                        @RequestParam(required = false, defaultValue = "1") @ApiParam(value = "分页第几页") Integer pageNum,
                                        @RequestParam(required = false, defaultValue = "10") @ApiParam(value = "每页多少记录") Integer pageSize);

    @RequestMapping(method = RequestMethod.GET, value = "/api/tenant/{id}")
    public BaseResponse getTenantById(@PathVariable @ApiParam(required = true, value = "id") String id);

    @RequestMapping(method = RequestMethod.PUT, value = "/api/tenant")
    public BaseResponse updateTenant(@RequestBody @ApiParam(value = "新信息", required = true) TenantDto tenant);

    @RequestMapping(method = RequestMethod.POST, value = "/api/tenant", consumes = {APPLICATION_JSON_UTF8_VALUE})
    public BaseResponse insertTenant(@RequestBody @ApiParam(value = "创建", required = true) TenantDto tenant);

    @RequestMapping(method = RequestMethod.DELETE, value = "/api/tenant/{id}")
    public BaseResponse deleteTenant(@PathVariable @ApiParam(value = "id", required = true) String id);
}
